/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.enterprise.web;

import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.assg2.dao.*;
import com.movie.Cinema;
import com.movie.Movie;
import com.movie.Owner;
import com.movie.Viewer;
import java.util.Set;
import javax.servlet.http.HttpSession;

/**
 * This is the command that will be used for logging in users.
 * If logon is successful, the command should place a list of contacts
 * in the request attriubutes.
 * @author  yunki
 */
public class AddShowCommand implements Command {

    /** Creates a new instance of LoginCommand */
    public AddShowCommand() {
    }

    public String execute(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        //TODO: set the response content type to "text/html" here
        //TODO: You'll have to use getWriter() to output some HTML texts
        //TODO: close the output stream

        //response.setContentType("text/html");// from response, set content type
        PrintWriter out = response.getWriter();// from response, get output writer

        HttpSession session = request.getSession(true);
        //return "//header.html").include(request, response);
        DaoOwner dow = new DaoOwner();
//        Owner owner = (Owner)request.getSession().getAttribute("user");
        if(((String)session.getAttribute("usertype")).matches("owner")){
           Owner owner = (Owner)session.getAttribute("user");
         
        
        Set<Cinema> cinemaSet = owner.getCinemas();
        request.setAttribute("cinemaset", cinemaSet);
        return "/addshowtime.jsp";}else {
                    request.setAttribute("message", "You dont have the right to do that:<a href='javascript:history.go(-1)'>Go to Back</a>");
                    return "message";
                }
        
        
        
        //return "/footer.html").include(request, response);
        //return null;
    }
}
